package oocl.ita.eordering.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import oocl.ita.eordering.po.Client;
import oocl.ita.eordering.service.ClientService;

@Controller
public class ClientController {
	
	@Autowired(required=true)
	private  ClientService cser;
	

	
	@RequestMapping("/login")
	public String login(String username,String password,HttpServletRequest request){
		
		
		Client c=cser.clientLogin(username,password);
		if(c!=null){
			request.getSession().setAttribute("c", c);
			System.out.println("suc");
			return "suc";
		}
		else{
			System.out.println("error..");
			return "login";
		}
		
		
	}
	@RequestMapping("/regist")
	public String regist(Client c,HttpServletRequest request){
		System.out.println("...person name....."+c.getcPersonName());
		System.out.println(c.getcLocation());
		System.out.println(c.getcPassword());
		System.out.println(c.getcTel());
		
		int rs=cser.clientRegist(c);
		if(rs>0)
		return "suc";
		else return "regist";
	}
	
	
	
	
	

}
